Flex中使用Shared Object—Use Shared Object In Flex

Categories: Flex; Tagged with: ; @ October 12th, 2008 14:13

Flex中的ShareObject类似于传统的cookie,但又具有传统cookies所不具有的优点:

1.默认情况下,不会过期
2.默认情况下,每个ShareObject的大小限制为100KB;
3.可以存储简单数据类型 :String,Array,Data等;
4.存储于程序制定的位置[在User的Home Directory中];
5.从不在客户端与服务器间传递

1.创建一个Shared Object

  			var NoteManagementShareObject:SharedObject = SharedObject.getLocal("NoteManagementShareObjectSave");

2.指定位置:

var NoteManagementShareObject:SharedObject = SharedObject.getLocal("NoteManagementShareObjectSave", "/");

3.保存数据

以保存XML数据为例:

  		public function save(givenXML:XML = null):void{
  			var NoteManagementShareObject:SharedObject = SharedObject.getLocal("NoteManagementShareObjectSave");
  			NoteManagementShareObject.data.catandnote = givenXML;
  			NoteManagementShareObject.flush();
  		}

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.